﻿/****************************** Module Header ******************************\
 * Module Name:  GlobalizationHelper.cs
 * Module Version:  1.0.0 (2011-12-5)
 * Copyright (c) AnyEB.Com (14507247@qq.com)
 * 
 * This class is used to encrypt string or encrypt number.
 * 
 * This source is subject to the GPL License.
 * See http://www.gnu.org/licenses/gpl.html.
 * All other rights reserved.
 * 
 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/

using System;
using System.Collections.Generic;
using System.Text;

namespace UCF.Core
{
    /// <summary>
    /// 国际化助手类
    /// </summary>
    public class GlobalizationHelper
    {
        #region 人文语言
        
        /// <summary>
        /// 批量翻译语言
        /// </summary>
        /// <param name="toLanguage"></param>
        /// <param name="codes"></param>
        /// <returns></returns>
        public string[] BatchTranslateLanguage(string toLanguage, params string[] codes)
        {
            string[] sarrOut = new string[codes.Length];
            int i = 0;
            foreach (String s in codes)
            {
                sarrOut[i] = this.TranslateLanguage(toLanguage, s);
                i++;
            }
            return sarrOut;
        }
        /// <summary>
        /// 翻译语言
        /// </summary>
        /// <param name="toLanguage"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public string TranslateLanguage(string toLanguage, string code)
        {
            string[] arrLanguage = new string[] { "中文", "英语", "韩语", "日语", "德语", "法语", "土耳其语", "阿拉伯语", "俄语" };
            string[] arrCodes = new string[] { "zh", "en", "kr", "ja", "de", "fr", "trk", "ar", "ru" };
            int i = Array.IndexOf<String>(arrCodes, code);
            if (i == -1) return "";
            return arrLanguage[i];
        }
        /// <summary>
        /// 语言代码
        /// </summary>
        public struct LanguageCode
        {
            /// <summary>
            /// 中文
            /// </summary>
            public static string zh { get { return "zh"; } }
            /// <summary>
            /// 英文
            /// </summary>
            public static string en { get { return "en"; } }
            /// <summary>
            /// 德语
            /// </summary>
            public static string de { get { return "de"; } }
            /// <summary>
            /// 法语
            /// </summary>
            public static string fr { get { return "fr"; } }
            /// <summary>
            /// 韩语
            /// </summary>
            public static string kr { get { return "kr"; } }
            /// <summary>
            /// 俄语
            /// </summary>
            public static string ru { get { return "ru"; } }
            /// <summary>
            /// 土耳其语
            /// </summary>
            public static string trk { get { return "trk"; } }
        }
        #endregion

        #region 数据解释,如性别、状态等的解释

        /// <summary>
        /// 解释性别
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public string ReadSexText(string value)
        {
            return (value == "0" || value == "female") ? "女士" : "先生";
        }
        /// <summary>
        /// 读取管理员状态
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public string ReadUserStateText(short value)
        {
            switch (value)
            {
                case -1:
                    return "禁用";
                case 0:
                    return "待审核";
                case 1:
                    return "正常";
            }
            return value.ToString();
        }
        #endregion

    }
}
